﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>授课内容</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link href="../../static/css/font.css" rel="stylesheet" />
    <link href="../../static/css/weadmin.css" rel="stylesheet" />
    <link href="../../lib/layui/css/layui.css" rel="stylesheet" />
    <script src="../../../lib/layui/layui.js"></script>

</head>
<body>
    <div class="layui-fluid" id="infos">
        <table id="dataList" lay-filter="dataList"></table>
    </div>
    <div class="layui-fluid fluid-position">
        <div class="layui-form">
            <div class="layui-card">
                <div class="layui-card-header">
                    <div class="layui-row layui-col-space10 layui-btn-container">

                        <button type="button" class="layui-btn layui-btn-primary" id="find" name="查询"><i class="layui-icon">&#xe615;</i>查询</button>
                        <button type="button" class="layui-btn layui-btn-primary" id="reset" name="清空"><i class="layui-icon">&#xe669;</i>清空</button>
                        <button type="button" class="layui-btn layui-btn-normal" id="add" name="添加保存"><i class="layui-icon">&#xe608;</i> 添加保存</button>
                        <button type="button" class="layui-btn layui-btn-normal" id="edit" lay-filter="edit" name="编辑保存" lay-submit><i class="layui-icon">&#xe642;</i>编辑保存</button>
                        <button type="button" class="layui-btn layui-btn-danger" id="del" name="删除"><i class="layui-icon">&#xe640;</i>删除</button>
                        <button type="button" class="layui-btn layui-btn-warm" id="check" name="审核"><i class="layui-icon">&#xe605;</i>审核</button>
                        <button type="button" class="layui-btn layui-btn-warm" id="uncheck" name="取消审核"><i class="layui-icon">&#x1006;</i>取消审核</button>
                        <button type="button" class="layui-btn layui-btn-warm layui-bg-cyan" id="release" name="发布"><i class="layui-icon">&#xe609;</i>发布</button>
                        <button type="button" class="layui-btn layui-btn-warm layui-bg-cyan" id="unrelease" name="取消发布"><i class="layui-icon">&#xe604;</i>取消发布</button>

                        <button type="button" class="layui-btn" name="导入"><i class="layui-icon">&#xe638;</i>导入</button>
                        <button type="button" class="layui-btn" name="导出"><i class="layui-icon">&#xe632;</i>导出</button>
                        <button type="button" class="layui-btn" name="打印"><i class="layui-icon">&#xe63c;</i>打印</button>
                    </div>
                </div>
                <div class="layui-card-body">
                    <div class="layui-collapse" lay-accordion lay-filter="infos_form">
                        <div class="layui-colla-item">
                            <h2 class="layui-colla-title">授课内容</h2>
                            <div class="layui-colla-content">
                                <div class="layui-form layui-form-pane">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">培训计划</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="培训计划" maxlength="50" class="layui-input" id="PrePlanName" name="PrePlanName" onclick="SelectGroup()" />
                                        </div>
                                    </div>
                                    <!--计划名称-->
                                    <!--<div class="layui-form-item">
                                        <label class="layui-form-label">计划名称</label>
                                        <div class="layui-input-block">
                                            <input type="text" placeholder="计划名称" class="layui-input" maxlength="50" id="TPName" name="TPName" />
                                        </div>
                                    </div>-->

                                    <!--时间-->
                                    <div class="layui-form-item">
                                        <!--<div class="layui-inline">
                                            <label class="layui-form-label">发布时间</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" id="TPReleaseStart" />
                                            </div>
                                            <label class="layui-form-label layui-form-label-inner layui-form-label-inner-w1">至</label>
                                            <div class="layui-input-inline layui-form-label-inner">
                                                <input type="text" class="layui-input" id="TPReleaseEnd" name="TPReleaseEnd" />
                                            </div>
                                        </div>-->
                                        <div class="layui-inline" style="display:none;">
                                            <label class="layui-form-label" >发布</label>
                                            <div class="layui-input-block">
                                                <select id="IsRelease" class="layui-tree-more" name="IsRelease">
                                                    <option value="">请选择</option>
                                                    <option value="0">未发布</option>
                                                    <option value="1">已发布</option>
                                                </select>
                                            </div>
                                        </div>

                                    </div>


                                    <div class="layui-form-item" id="selectDeptShow">
                                        <div class="layui-form-label">选择部门</div>
                                        <div class="layui-input-block">
                                            <input type="text" autocomplete="off" readonly="" id="selectDatas" name="selectDatas" placeholder="请选择" class="layui-input" />
                                            <div class="eleTree" lay-filter="data5"></div>
                                        </div>
                                    </div>

                                    <!--计划描述-->
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">授课内容</label>
                                        <div class="layui-input-block">
                                            <textarea name="" placeholder="授课内容" class="layui-textarea" maxlength="500" id="TContent"></textarea>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>

                </div>
                <div class="layui-card-header layui-btn-container">

                </div>
            </div>
        </div>
    </div>

    <script>
        var ModleNameTip = "授课内容";  //模块名称  用于提示部门信息的内容  
        var contollerName = "TrainContent";//api url的一部分  ，控制器名 
        var load = 1;
        var CPID = 0;//所属集团计划id  带过来的 或者直接选过来的
        var prePlanId = 0;//选择的上级培训计划id
        var selectIDs = [];//选中的id列表 [可用批量删除  审核 取消 ]
        var selectCurrentID = 0;// 当前选中的 id  [用于修改]
        var currentDeptLevelId = 0;//当前登录者 部门级别  0：是段
        var currentInfoDeptLevelId = 0;//当前选中信息的  部门级别  [用于判断 是否能够对 该条信息进行修改:下级不能对上级的计划信息进行修改]
        var cuurentDeptId = 0;//当前部门id

        var selectCurrentIsCheckStatus = 0;// 当前选中的行的 IsChck 状态  [用于删除/审核/取消审核/发布/取消发布时判断]
        var selectCurrentIsReleaseStatus = 0;// 当前选中的行的 IsRelease 状态  [用于删除/审核/取消审核/发布/取消发布时判断]

        var currentInfoDeptId = 0;//当前选中信息的 部门id
        var selectobjs = [];//
        //加载 [赋值]获取数据  (部门相关数据)
        var dataSelect = [];
        var temp_deptId_List = [];//列表中选择信息时   使用字段中的内容=>为其赋值,可以使用此字段保存
        var dataCurent = [];
        var th = 0;
        var tw = 0;
        //选择上级计划/集团计划 【段筛选 集团计划， 下级都筛选培训计划  根据当前部门级别来判断， 段是0】
        function SelectGroup() {
            layui.use(['layer', 'jquery'], function () {
                var h = th*1.8;
                var w = tw * 0.8;
                var layer = layui.layer;
                var $ = layui.jquery;
                var contentPage = "../plan/trainplan_SelectList.html?plan=2";
                var title = "选择培训计划";
                layer.open({
                    title: title,
                    type: 2,
                    area: [w + "px", h + "px"],
                    btn: ['确定'],
                    content: contentPage,
                    yes: function (index) {
                        var res = window["layui-layer-iframe" + index].selectdata();
                        $("#PrePlanName").val(res.RefName);
                        prePlanId = res.RefID;
                        CPID = res.CPID;
                        layer.close(index);
                    }
                });
            });
        };
        layui.use(['form', 'laydate', 'table', 'jquery', 'element', 'layer', 'tree', 'util'], function () {
            var laydate = layui.laydate;
            var $ = layui.jquery;
            th = $(document).height() * 0.5;
            tw = $(document).width();
            var table = layui.table;
            var form = layui.form;
            var element = layui.element;
            var layer = layui.layer;
            var eleTree = layui.tree;
            $(".layui-card-header").find("button").each(function () { if (PowerList.indexOf($(this).attr("name")) <= -1) { $(this).attr("style", "display:none;") } });
            form.on('switch(switch)', function (data) { });
            laydate.render({ elem: '#TPReleaseStart', trigger: 'click' });
            laydate.render({ elem: '#TPReleaseEnd', trigger: 'click' });
            function PageInit() {
                var obj = $("div[lay-id='dataList']");
                var child = $(".layui-table-body");
                var off = obj.offset().top;
                var c = th - off - 100;
                child.attr("style", "height:" + c + "px");
            }
            element.on('collapse(infos_form)', function (data) {
                PageInit();
            });

            //获取当前 部门级别id,部门id
            $.ajax({
                url: ApiUrl + "Dep/DeptLevel",//SelTree
                type: 'post',
                headers: {
                    "userid": JSON.parse(window.localStorage.authInfo).UserId,
                    "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                },
                success: function (data) {
                    if (data.StatusCode == 200) {
                        currentDeptLevelId = data.Data.currentDeptLevelId;
                        cuurentDeptId = data.Data.cuurentDeptId;
                        GetDept(cuurentDeptId);
                    }
                    else if (data.StatusCode == 403) {
                        layer.alert(data.Info, function () {
                            top.location.href = "http://" + top.location.host + "/login.html";
                        })
                    }
                    else {
                        layer.msg(data.Info);
                    }
                }
            });
            //获取下级部门列表树
            function GetDept(deptid)
            {
                var  r = 0;
                $.ajax({
                    url: ApiUrl + "Dep/SelNextTree",//SelTree
                    type: 'post',
                    async: false,
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    data: { DepID: deptid },
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            dataSelect = data.Data;
                            loadTree();
                            r = 1;
                            if (dataSelect.length <= 0) {
                                $("#selectDeptShow").attr("style", "display:none;");
                            }
                            else {
                                $("#selectDeptShow").attr("style", "display:block;");
                            }
                        }
                        else if (data.StatusCode == 403) {
                            layer.alert(data.Info, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
                return r;
            }
            function GetSinglePlan(TPID) {
                $.ajax({
                    url: ApiUrl + "TrainPlan/GetSingle?TPID="+TPID,
                    type: 'get',
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            $("#PrePlanName").val(data.Data.TPName);
                        }
                        else if (data.StatusCode == 403) {
                            layer.alert(data.Info, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
            }
            var tempList = [];
            function SetTextFromTree(v) {
                for (var i = 0; i < v.length; i++) {
                    var c = v[i];
                    tempList.push({ id: c.id, title: c.title });
                    temp_deptId_List.push(c.id);
                    var a = $("#selectDatas").val();
                    if (a != "") { a += ","; }
                    $("#selectDatas").val(a + c.title);
                    if (c.children != undefined) {
                        if (c.children.length > 0) {
                            SetTextFromTree(c.children);
                        }
                    }
                }
            }

            function setTree()//选择信息列表中 信息时 调用该方法  并为temp_deptId_List赋值
            {
                eleTree.setChecked('eleTreeid', temp_deptId_List);
            }

            var el_tree;
            $("#selectDatas").on("click", function (e) {
                e.stopPropagation();
                loadTree();
                $(".eleTree").toggle();
            });

            function loadTree() {
                el_tree =
                    eleTree.render({
                        elem: '.eleTree',
                        id: 'eleTreeid',
                        data: dataSelect,
                        defaultExpandAll: false,
                        expandOnClickNode: false,
                        highlightCurrent: true
                        , checkStrictly: true
                        , showCheckbox: true
                        , oncheck: function (obj) {
                            $("#selectDatas").val("");
                            temp_deptId_List = [];
                            tempList = [];
                            SetTextFromTree(el_tree.getChecked());
                        }
                    });
            }
            function showList() {
                var swhere = JSON.stringify({
                    TContent: $("#TContent").val(),
                    //IsRelease: $("#IsRelease").val(),
                    IsUse: 1,
                    self:0
                });
                table.render({
                    elem: '#dataList'
                    , url: ApiUrl+contollerName+'/Search'
                    , id: "dataList"
                    , headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    }
                    , page: true
                    , cols: [[
                        { type: 'checkbox' },
                        { field: 'TCID', title: '编号', sort: true, hide: true }, 
                        { field: 'TPID', title: '计划id', sort: true, hide: true },
                        { field: 'AutoID', title: 'AutoID', sort: true, hide: true }, 
                        { field: 'TContent', title: '授课内容', width: 300 },
                        { field: 'AddUserID', title: '添加人员id', hide: true },
                        { field: 'AddUserName', title: '添加人员姓名' },
                        {
                            field: 'AddDateTime', title: '添加时间', width: 120, templet: function (d) {
                                return d.AddDateTime.substring(0, 10);
                            },
                        },
                        { field: 'TCDepID', title: '部门', hide: true },
                        { field: 'TCDepLevel', title: '部门级别', hide: true },
                        { field: 'TCSendDepID', title: '下发部门', hide: true },
                        {
                            field: 'IsCheck', title: '审核', width: 100, templet: function (d) {
                                return d.IsCheck == "0" ? "未审核" : "已审核";
                            }
                        },
                        {
                            field: 'IsRelease', title: '发布', width: 100, templet: function (d) {
                                return d.IsRelease == "0" ? "未发布" : "已发布";
                            }
                        },
                       //{ field: 'IsUse', title: '使用状态', width: 100, templet: function (d) { return d.IsUse == "0" ? "未用" : "在用" } }
                    ]]
                    , where: { swhere: swhere }
                    , parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    page: true,
                    done: function (res, curr, count) {
                        //如果是异步请求数据方式，res即为你接口返回的信息。
                        //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                    }
                });
            }
            showList();
            $(function () {
                $("del").hide();
                document.getElementById("edit").style.display = "none";
                document.getElementById("edit").style.display = "inline";
                $("#sreach").click(function () {
                    showList();
                })
            })
            PageInit();
            function clearForm() {
                $("textarea").val("");
                $("input").val("");
                $("#IsRelease").val("");
            }

            //展示一条信息
            function GetSingleInfo(data) {
                //$("#TPName").val(data.TPName);
                $("#TContent").val(data.TContent);
                //$("#TPReleaseStart").val(data.TPReleaseStart.split('T')[0]);
                //$("#TPReleaseEnd").val(data.TPReleaseEnd.split('T')[0]);
                $("#IsRelease").val(data.IsRelease);
                if (data.TPID != null) {
                    prePlanId = data.TPID;
                    GetSinglePlan(data.TPID);
                }
                //CPID = data.CPID;
                temp_deptId_List = [];
                currentInfoDeptLevelId = data.TCDepLevel;
                currentInfoDeptId = data.TCDepID;
                var r = GetDept(currentInfoDeptId);
                if (r==1)
                {
                    if (data.TCSendDepID != null) {
                        if (data.TCSendDepID.indexOf(',') > -1) {
                            var tpids = data.TCSendDepID.split(',');
                            for (var i = 0; i < tpids.length; i++) {
                                temp_deptId_List.push(Number(tpids[i]));
                            }
                        }
                        else {
                            temp_deptId_List.push(Number(data.TCSendDepID));
                        }
                        setTree();
                    }
                }
                //add by cjh
                selectCurrentIsCheckStatus = data.IsCheck;
                selectCurrentIsReleaseStatus = data.IsRelease;
            }

            ///按钮操作 开始
            //监听行单击事件（单击事件为：rowDouble）  //别的模块 需要替换id=》TCID
            table.on('row(dataList)', function (obj) {
                var checked = false;
                var objcheck = $(obj.tr.selector).find("td").eq(0).find(".layui-table-cell").eq(0).find("div").eq(0);
                if (selectIDs.indexOf(obj.data.TCID)> -1) {
                    objcheck.removeClass("layui-form-checked");
                }
                else {
                    objcheck.addClass("layui-form-checked"); checked = true;
                }
                if (checked) {
                    if (obj.data.TCID != undefined) {
                        selectCurrentID = obj.data.TCID;
                        selectIDs.push(obj.data.TCID);
                        selectobjs.push(obj.data);
                        GetSingleInfo(obj.data);
                    }
                    else {
                        selectIDs = [];
                        selectCurrentID = 0;
                        selectobjs = [];
                        var dataList = table.checkStatus("dataList").data;
                        for (var i = 0; i < dataList.length; i++) {
                            var item = dataList[i];
                            selectobjs.push(item);
                            selectIDs.push(item.TCID);
                            if (i == dataList.length - 1) {
                                GetSingleInfo(item);
                                selectCurrentID = item.TCID;
                            }
                        }
                    }
                }
                else {
                    if (obj.data.TCID != undefined) {
                        selectIDs.splice(selectIDs.indexOf(obj.data.TCID), 1);
                        for (var i = 0; i < selectobjs.length; i++) {
                            if (selectobjs[i].TCID == obj.data.TCID) {
                                if (i == selectobjs.length - 1) {
                                    selectCurrentID = 0;
                                    selectCurrentName = "";
                                    if (i > 0) {
                                        if (selectobjs[i - 1].TCID != undefined) {
                                            selectCurrentID = selectobjs[i - 1].TCID;
                                            GetSingleInfo(selectobjs[i - 1]);
                                        }
                                    }
                                    else {
                                        clearForm(); selectCurrentID = 0;
                                    }
                                }
                                selectobjs.splice(i, 1);
                                break;
                            }
                        }
                        if (selectIDs<=0)
                        {
                            temp_deptId_List = [];
                            var r = GetDept(cuurentDeptId);
                            if (r == 1) {
                                setTree();
                            }
                        }
                    }
                    else {
                        selectIDs = [];
                        selectCurrentID = 0;
                        selectobjs = [];
                        clearForm();
                        temp_deptId_List = [];
                        var r = GetDept(cuurentDeptId);
                        if (r == 1) {
                                setTree();
                         }
                    }
                }
            });
            table.on('checkbox(dataList)', function (obj) { //别的模块 需要替换id=>TCID
                if (obj.data.AutoID == undefined) {
                    selectIDs = [];
                    selectCurrentID = 0;
                    selectobjs = [];
                    if (obj.checked) {
                        var dataList = table.checkStatus("dataList").data;
                        for (var i = 0; i < dataList.length; i++) {
                            var item = dataList[i];
                            selectobjs.push(item);
                            selectIDs.push(item.TCID);
                            if (i == dataList.length - 1) {
                                GetSingleInfo(item);
                                selectCurrentID = item.TCID;
                            }
                        }
                    }
                    else {
                        selectIDs = [];
                        selectCurrentID = 0;
                        selectobjs = [];
                        clearForm();
                        temp_deptId_List = [];
                        var r = GetDept(cuurentDeptId);
                        if (r == 1) {
                            setTree();
                        }
                    }
                }
            });

            $("#find").click(function () {
                showList();
            });

            $("#reset").click(function () {
                clearForm();
                temp_deptId_List = [];
                selectCurrentID = 0;
                GetDept(cuurentDeptId);
                setTree();
            });

            //校验数据
            function CheckData() {
                if (prePlanId <= 0) {
                    layer.msg("请选择培训计划！");
                    return false;
                }
                if ($("#TContent").val().trim() == "") {
                    layer.msg("请输入授课内容！");
                    return false;
                }
                return true;
            }
            //获得数据
            function GetFormData() {
               // var TPName = $("#TPName").val();//计划名称
               // var ID = CPID;//prePlanId;//集团id
                var TPID = prePlanId;// prePlanId;//培训计划id
                var TContent = $("#TContent").val();
                //var TPReleaseStart = $("#TPReleaseStart").val();
                //var TPReleaseEnd = $("#TPReleaseEnd").val();
                return model = {
                    //TPName: TPName,
                    //CPID: ID,
                    TPID: TPID,
                    TContent: TContent,
                    //TPReleaseStart: TPReleaseStart,
                    //TPReleaseEnd: TPReleaseEnd,
                    TCSendDepID: temp_deptId_List.toString(),
                    IsRelease: false,
                    IsCheck: false,
                    IsUse: true
                }
            }
            //判断当前 能否操作该信息
            function GetOperate(operRatetype, pcurrentInfoDeptLevelId)
            {
                //operRatetype:操作类型     pcurrentInfoDeptLevelId:当前需要操作的信息的  部门级别
                //operRatetype[1:修改，2：删除,3:审核,4:取消审核,5:发布 6:取消发布]
                var result = true;
                if (currentDeptLevelId > pcurrentInfoDeptLevelId) {
                    switch (operRatetype) {
                        case 1:
                            layer.msg("您没有权限，不能修改上级计划");
                            result = false;
                            break;
                        case 2:
                            layer.msg("您没有权限，不能删除上级计划");
                            result = false;
                            break;
                        case 3:
                            layer.msg("您没有审核权限，不能对该条信息进行审核");
                            result = false;
                            break;
                        case 4:
                            layer.msg("您没有取消审核权限，不能对该条信息进行取消审核");
                            result = false;
                            break;
                        case 5:
                            layer.msg("您没有发布信息权限，不能对该条信息进行发布");
                            result = false;
                            break;
                        case 6:
                            layer.msg("您没有取消发布权限，不能对该条信息进行取消发布");
                            result = false;
                            break;
                    }
                }
                return result;
            }

            //添加保存
            $("#add").click(function () {
                if (selectCurrentID > 0) {
                    layer.msg("请先清空在进行添加保存操作!"); return;
                }
                if (!CheckData()) { return; }
                $.ajax({
                    url: ApiUrl+contollerName+"/Add",
                    type: 'post',
                    dataType: 'json',
                    cache: false,
                    data: GetFormData(),
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    success: function (data) {
                        if (data.StatusCode == 200 && data.Count != 0) {
                            layer.alert("添加保存成功", { icon: 6 }, function (index) {
                                layer.close(index);
                                location.reload();
                            })
                        }
                        else if (data.StatusCode == 403) {
                            top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
            });

            
            //编辑保存
            form.on('submit(edit)', function (formdata) {
                if (selectCurrentID <= 0) {
                    layer.msg("请选择一条信息!"); return;
                }
                if (!GetOperate(1, currentInfoDeptLevelId)) { return; }
                if (!CheckData()) { return; }
                var model = GetFormData();
                model.TCID = selectCurrentID;
                //编辑保存 selectCurrentID
                $.ajax({
                    url: ApiUrl+contollerName+"/Edit",
                    type: 'post',
                    dataType: 'json',
                    data: model,
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    success: function (data) {
                        if (data.StatusCode == 200 && data.Count != 0) {
                            layer.alert(data.Info, { icon: 6 }, function (index) {
                                layer.close(index);
                                location.reload();
                            })
                        }
                        else if (data.StatusCode == 403) {
                            top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });

            });

            //删除
            $("#del").click(function () {

                if (!GetOperate(2, currentInfoDeptLevelId)) { return; }
                if (selectIDs.length == 0) {
                    layer.msg("请选择要删除的计划！");
                    return;
                }
                if (selectCurrentIsCheckStatus == 1) {
                    layer.msg("已审核不能删除！");
                    return;
                }
                if (selectCurrentIsReleaseStatus == 1) {
                    layer.msg("已发布不能删除！");
                    return;
                }
                layer.confirm('确定要删除吗?', function (index) {


                    var delList = '';
                    for (var i = 0; i < selectIDs.length; i++) {
                        delList += selectIDs[i] + ',';
                    }

                    delList = delList.substring(0, delList.length - 1);

                    $.ajax({
                        url: ApiUrl +contollerName+"/DelList",
                        type: 'get',
                        cache: false,
                        headers: {
                            "userid": JSON.parse(window.localStorage.authInfo).UserId,
                            "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                        },
                        data: { delidlist: delList },
                        success: function (data) {
                            if (data.StatusCode == 200) {
                                layer.alert("删除成功", { icon: 6 }, function (index) {
                                    layer.close(index);
                                    location.reload();
                                })
                            }
                            else if (data.StatusCode == 403) {
                                layer.alert(data.Info, function () {
                                    top.location.href = "http://" + top.location.host + "/login.html";
                                })
                            }
                            else {
                                layer.msg(data.Info);
                            }
                        }
                    });


                    //删除 selectIDs
                    layer.close(index);
                });
            });
            //审核
            $("#check").click(function () {
                //审核 selectIDs
                //alert("审核");

                if (!GetOperate(3, currentInfoDeptLevelId)) { return; }
                if (selectCurrentID == 0) {
                    layer.msg("请选择要审核的" + ModleNameTip+"！");
                    return;
                }
                if (selectCurrentIsCheckStatus == 1) {
                    layer.msg("选择的" + ModleNameTip+"已审核！");
                    return;
                }
                $.ajax({
                    url: ApiUrl +contollerName+"/UpdatePlanStatus",
                    type: 'get',
                    cache: false,
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    data: { mark: 'C', value: '1', wherevalue: selectCurrentID },
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            layer.alert("审核成功", { icon: 6 }, function (index) {
                                layer.close(index);
                                location.reload();
                            })
                        }
                        else if (data.StatusCode == 403) {
                            layer.alert(data.Info, function () {
                                //location.href = './login.html';
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });

            });
            //取消审核
            $("#uncheck").click(function () {
                if (!GetOperate(4, currentInfoDeptLevelId)) { return; }
                if (selectCurrentID == 0) {
                    layer.msg("请选择要取消审核的" + ModleNameTip+"！");
                    return;
                }
                if (selectCurrentIsCheckStatus == "0") {
                    layer.msg("选择的" + ModleNameTip+"未审核！");
                    return;
                }

                layer.confirm('确定要取消审核吗?', function (index) {
                    //取消审核 selectIDs
                    //alert("已取消审核");


                    $.ajax({
                        url: ApiUrl+contollerName+"/UpdatePlanStatus",
                        type: 'get',
                        cache: false,
                        headers: {
                            "userid": JSON.parse(window.localStorage.authInfo).UserId,
                            "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                        },
                        data: { mark: 'C', value: "0", wherevalue: selectCurrentID },
                        success: function (data) {
                            if (data.StatusCode == 200) {
                                layer.alert("取消审核成功", { icon: 6 }, function (index) {
                                    layer.close(index);
                                    location.reload();
                                })
                            }
                            else if (data.StatusCode == 403) {
                                layer.alert(data.Info, function () {
                                    top.location.href = "http://" + top.location.host + "/login.html";
                                })
                            }
                            else {
                                layer.msg(data.Info);
                            }
                        }
                    });


                    layer.close(index);
                });
            });
            //发布
            $("#release").click(function () {
                //alert("release");
                if (!GetOperate(4, currentInfoDeptLevelId)) { return; }
                if (selectCurrentID == 0) {
                    layer.msg("请选择要发布的" + ModleNameTip+"！");
                    return;
                }
                if (selectCurrentIsCheckStatus == "0") {
                    layer.msg("选择的" + ModleNameTip+"未审核！");
                    return;
                }
                if (selectCurrentIsReleaseStatus == 1) {
                    layer.msg("选择的" + ModleNameTip+"已发布！");
                    return;
                }
                $.ajax({
                    url: ApiUrl + contollerName+"/UpdatePlanStatus",
                    type: 'get',
                    cache: false,
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    data: { mark: 'R', value: '1', wherevalue: selectCurrentID },
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            layer.alert("发布成功", { icon: 6 }, function (index) {
                                layer.close(index);
                                location.reload();
                            })
                        }
                        else if (data.StatusCode == 403) {
                            layer.alert(data.Info, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
                //发布 selectIDs
            });
            //取消发布
            $("#unrelease").click(function () {
                if (!GetOperate(6, currentInfoDeptLevelId)) { return; }
                if (selectCurrentID == 0) {
                    layer.msg("请选择要取消发布的" + ModleNameTip+"！");
                    return;
                }
                if (selectCurrentIsReleaseStatus == 0) {
                    layer.msg("选择的" + ModleNameTip+"未发布！");
                    return;
                }
                layer.confirm('确定要取消发布吗?', function (index) {
                    //conso.log("已取消发布");

                    $.ajax({
                        url: ApiUrl+contollerName+"/UpdatePlanStatus",
                        type: 'get',
                        cache: false,
                        headers: {
                            "userid": JSON.parse(window.localStorage.authInfo).UserId,
                            "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                        },
                        data: { mark: 'R', value: "0", wherevalue: selectCurrentID },
                        success: function (data) {
                            if (data.StatusCode == 200) {
                                layer.alert("取消发布成功", { icon: 6 }, function (index) {
                                    layer.close(index);
                                    location.reload();
                                })
                            }
                            else if (data.StatusCode == 403) {
                                layer.alert(data.Info, function () {
                                    top.location.href = "http://" + top.location.host + "/login.html";
                                })
                            }
                            else {
                                layer.msg(data.Info);
                            }
                        }
                    });

                    layer.close(index);
                    //取消发布 selectIDs
                });
            });


            //end
        });
    </script>
</body>
</html>